package com.dream.cgomall.controller;

import com.dream.cgomall.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * ES控制器
 */
@RestController
@RequestMapping("es")
public class ContentController {
    @Autowired
    ContentService contentService;

    @GetMapping("/parseDiscover")
    public boolean parseDiscover() throws IOException {
        return contentService.parseContent();
    }

    @RequestMapping("/searchPage")
    public List<Map<String, Object>> searchPage(String keyword, String from, String to) throws IOException {
        List<Map<String, Object>> result = contentService.searchPage(keyword, Integer.parseInt(from), Integer.parseInt(to));
        return result;
    }

}
